package com.example.projectmanagement.repository.study;

import com.example.projectmanagement.model.study.Module;
import com.example.projectmanagement.model.study.Course;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import java.util.List;

@Repository
public interface ModuleRepository extends JpaRepository<Module, Long> {
    List<Module> findByCourseOrderByDisplayOrderAsc(Course course);
    
    @Query("SELECT m FROM Module m WHERE m.course.id = :courseId ORDER BY m.displayOrder ASC")
    List<Module> findByCourseIdOrderByDisplayOrderAsc(@Param("courseId") Long courseId);
}